# -*- coding:utf-8 -*-
try:
    import maya.cmds as cmds
except Exception as test_ERR:
    print('test')


def face_material():
    default_mat = [u'initialParticleSE', u'initialShadingGroup']
    ses = cmds.ls(type='shadingEngine')
    has_face = []
    for se in ses:
        if se not in default_mat:
            con = cmds.sets(se, q=True)
            for c in con:
                if c.count('f[') > 0 and se not in has_face:
                    has_face.append(se)
    return has_face




def _run():
    try:
        wrong = face_material()
        if wrong:
            choose = cmds.confirmDialog(title='result', message=u'面上材质:\n' + str(wrong), icon='warning',
                                        button=['OK'], defaultButton=u'OK', cancelButton=u'OK',
                                        dismissString=u'OK')  # , dismissString=u'取消'
    except Exception as face_material_detect_ERR:
        print('face_material_detect_ERR:',str(face_material_detect_ERR))



def _doc():
    doc = {'name':u'面上材质检测','doc':'检测是否有材质按面上材质'}
    return doc